package com.yic.module.mes.dal.mysql.processRoute;

import java.util.*;

import com.yic.framework.common.pojo.PageResult;
import com.yic.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yic.framework.mybatis.core.mapper.BaseMapperX;
import com.yic.module.mes.dal.dataobject.processRoute.ProcessRouteDO;
import com.yic.module.mes.dal.dataobject.processrouteinfo.ProcessRouteInfoDO;
import org.apache.ibatis.annotations.Mapper;
import com.yic.module.mes.controller.admin.processRoute.vo.*;

/**
 * 工艺路线 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface ProcessRouteMapper extends BaseMapperX<ProcessRouteDO> {

    default PageResult<ProcessRouteDO> selectPage(ProcessRoutePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProcessRouteDO>()
                .likeIfPresent(ProcessRouteDO::getName, reqVO.getName())
                .likeIfPresent(ProcessRouteDO::getCode, reqVO.getCode())
                .eqIfPresent(ProcessRouteDO::getStatus, reqVO.getStatus())
                .eqIfPresent(ProcessRouteDO::getFactoryId, reqVO.getFactoryId())
                .orderByDesc(ProcessRouteDO::getId));
    }

    default List<ProcessRouteDO> selectList(ProcessRouteExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ProcessRouteDO>()
                .likeIfPresent(ProcessRouteDO::getName, reqVO.getName())
                .likeIfPresent(ProcessRouteDO::getCode, reqVO.getCode())
                .eqIfPresent(ProcessRouteDO::getStatus, reqVO.getStatus())
                .eqIfPresent(ProcessRouteDO::getFactoryId, reqVO.getFactoryId())
                .orderByDesc(ProcessRouteDO::getId));
    }

    default ProcessRouteDO selectByCode(String code) {
        return selectOne(new LambdaQueryWrapperX<ProcessRouteDO>()
                .eq(ProcessRouteDO::getCode, code));
    }
}
